<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *客户列表
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$tabs=array(
	array('op'=>'list','title'=>'客户列表'),
);
if($_SESSION['juese_id']!=6){
	exi('您无权访问！','error');
}
//$return['stores']=$this->getall('store',array('uniacid'=>$_SESSION['uniacid']),array('id','title'),'id');
$return['workers']=$this->getall('worker',array('storeid'=>$_SESSION['storeid'],'uniacid'=>$_SESSION['uniacid']),array('id','title'),'id');	
//客户列表
if($_RQ['op']=='list'){
	$this->model('member')->up_haidata();
	$orderby='createtime desc, up_time asc, id desc';
	$return['params']=array();
	$params=array('workerheid'=>$_SESSION['workerid'],'uniacid'=>$_SESSION['uniacid']);
	if($_RQ['jibie_type'] && $_RQ['jibie_type']!='all'){
		$params['jibie_type']=intval($_RQ['jibie_type']);
	}
	$return['params']['jibie_type']=$_RQ['jibie_type']?:'all';
	if($_RQ['status'] && $_RQ['status']!='all'){
		if($_RQ['status']==2 || $_RQ['status']==5 || $_RQ['status']==6 || $_RQ['status']==7 || $_RQ['status']==8 || $_RQ['status']==9 || $_RQ['status']==31 || $_RQ['status']==32 || $_RQ['status']==33 || $_RQ['status']==34){
			$params['status']=array(2,5,6,7,8,9,31,32,33,34);
		}elseif($_RQ['status']>=10 && ($_RQ['status']<=20 || $_RQ['status']==35 || $_RQ['status']==36 || $_RQ['status']==37 || $_RQ['status']==38)){
			$params['status']=array(10,11,12,13,14,15,16,17,18,19,20,35,36,37,38);
		}elseif($_RQ['status']==101 || $_RQ['status']==102 || $_RQ['status']==103 || $_RQ['status']==104 || $_RQ['status']==105 || $_RQ['status']==106){
			$params['status']=array(101,102,103,104,105,106);
		}elseif($_RQ['status']=='huifang'){
			$params['status']=32;
			$params['huifang_time >']=100;
			$orderby='huifang_time asc,id desc';
			$return['params']['status']=$_RQ['status'];
		}else{
			$params['status']=intval($_RQ['status']);
		}
		$return['params']['status']=$_RQ['status'];
	}
	if($_RQ['storeid']){
		$params['storeid']=intval($_RQ['storeid']);
		$return['params']['storeid']=$_RQ['storeid'];
	}
	if($_RQ['xueli']){
		$params['xueli']=intval($_RQ['xueli']);
		$return['params']['xueli']=$_RQ['xueli'];
	}
	if($_RQ['from1_type']){
		$params['from1_type']=intval($_RQ['from1_type']);
		$return['params']['from1_type']=$_RQ['from1_type'];
	}
	if(!empty($_RQ['title'])){
		$params['title like']='%'.$_RQ['title'].'%';
		$return['params']['title']=$_RQ['title'];
	}
	if(!empty($_RQ['mobile'])){
		$params['mobile']=$_RQ['mobile'];
		$return['params']['mobile']=$_RQ['mobile'];
	}
	if($_RQ['createtime']){
		$time_range=cfc('tools')->base64_decode($_RQ['createtime'],$_SESSION['base_key_str']);
		$time_range=json_decode($time_range,true);
		$params['createtime between']=array($time_range['tstart'],$time_range['tend']);
		$return['params']['createtime']=$time_range;
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = $_RQ['psize']?:30;
	if($_RQ['psize']){
		$return['params']['psize']=$_RQ['psize'];
	}
	$list=pdo_getslice('jy_yxw_member',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	if($list){
		foreach($list as &$item){
			$item['member']=$this->model('member')->member_show($item['id']);
			if($item['jibie_type']==5 && $item['status']!=-1){
				pdo_update('jy_yxw_member',array('status'=>-1),array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['id']));
			}
			if($item['from_type']==1){
				$item['from_typetitle']=$this->member_from1_type[$item['from1_type']];
			}elseif($item['from_type']==2){
				$item['from_typetitle']=$this->member_from2_type[$item['from2_type']];
			}else{
				$item['from_typetitle']=$this->member_from_type[$item['from_type']];
			}
			$item['jibie_typetitle']=$this->member_jibie_type[$item['jibie_type']];
			if(in_array($item['status'],array(-1,2,5,6,7,8,9,31,32,33,34))){
				$item['edit']=1;
			}else{
				$item['edit']=0;
			}
			$jiaofee1=pdo_getcolumn('jy_yxw_infee_log',array('memberid'=>$item['id'],'uniacid'=>$_SESSION['uniacid'],'type'=>1,'status'=>1),'id');
			if($jiaofee1){
				$item['jiaofee1']=1;
			}else{
				$item['jiaofee1']=0;
			}
			$jiaofee2=pdo_getcolumn('jy_yxw_infee_log',array('memberid'=>$item['id'],'uniacid'=>$_SESSION['uniacid'],'type'=>2,'status'=>1),'id');
			if($jiaofee2){
				$item['jiaofee2']=1;
			}else{
				$item['jiaofee2']=0;
			}
			$item['up_time']=$item['up_time']?date('Y/m/d',$item['up_time']):'无';
			$item['createtime']=date('Y/m/d',$item['createtime']);
			$item['worker6title']=pdo_getcolumn('jy_yxw_worker',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['worker6id']),'title');
			$item['worker6title']=$item['worker6title']?:'无';
			if($item['workerheid']){
				$workerhe=pdo_get('jy_yxw_worker',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['workerheid']),array('juese','title'));
				$item['workerhetitle']=$this->user_juese[$workerhe['juese']].':'.$workerhe['title'];
			}
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	//页面显示设置
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'export'=>'export',
		'list'=>array('data'=>'list','del_message'=>'确认删除该客户吗？','total'=>$total,'psize'=>$psize,'del_op'=>'del','del_one'=>false,'delall'=>false,'edit'=>false,'list'=>array(
			array('name'=>'member','title'=>'会员信息','type'=>'member'),
			//array('name'=>'storeid','title'=>'所属门店','type'=>'select','options'=>'stores'),
			array('name'=>'jibie_typetitle','title'=>'客户级别','type'=>'string','edit'=>'edit','edit_action'=>'jy_yxw/juese6.list/setjibie_type'),
			array('name'=>'from_typetitle','title'=>'渠道','type'=>'string'),
			array('title'=>'网络员','name'=>'worker3id','type'=>'select2','options'=>'workers'),
			array('title'=>'前台专员','name'=>'worker4id','type'=>'select2','options'=>'workers'),
			array('title'=>'电客员','name'=>'worker5id','type'=>'select2','options'=>'workers'),
			array('type'=>'img_string','title'=>'合作销售',
            'data'=>array(
                array('title'=>'销售员:','name'=>'worker6title'),
                array('title'=>'','name'=>'workerhetitle'),
                )
            ),
			array('title'=>'体验员','name'=>'worker7id','type'=>'select2','options'=>'workers'),
			array('title'=>'试用员','name'=>'worker8id','type'=>'select2','options'=>'workers'),
			array('name'=>'status','title'=>'状态','type'=>'radio2','options'=>'status'),
			array('name'=>'up_time','title'=>'最近跟进时间','type'=>'string'),
			array('name'=>'createtime','title'=>'添加时间','type'=>'string'),
			array('type'=>'href','action'=>'/member.genjin_log/onelist/','title'=>'查看跟进记录'),
		),'action'=>array(	
			//array('type'=>'href','action'=>'jy_yxw/juese6.list/edit','title'=>'完善客户信息','show'=>array('status'=>array(-1,2,5,6,7,8,9,31,32,33,34))),
			//array('type'=>'href','op'=>'setgenjin_log','title'=>'处理电客情况','show'=>array('status'=>array(1,2,30,31))),
			array('type'=>'modal','action'=>'jy_yxw/juese6.list/jiaofee2','title'=>'交定金','show'=>array('jiaofee2'=>0,'status'=>array(4,32,33,34,40,41,42,5,6,7,8,10))),
			array('type'=>'modal','action'=>'jy_yxw/juese6.list/jiaofee2','title'=>'重新交定金','show'=>array('status'=>array(39))),
			array('type'=>'href','action'=>'jy_yxw/juese6.list/jiaofee1','title'=>'成交提交','show'=>array('jiaofee1'=>0,'status'=>array(4,32,6,8,9))),
			array('type'=>'href','action'=>'jy_yxw/juese6.list/jiaofee1','title'=>'重新成交提交','show'=>array('status'=>array(38,105))),
			array('type'=>'href','action'=>'jy_yxw/xiaoshou.setgenjin_log/set6/','title'=>'处理跟进','show'=>array('status'=>array(-1,2,4,6,8,32,33,34))),
			//array('type'=>'href','op'=>'setgenjin_log7','title'=>'处理体验情况','show'=>array('status'=>array(5))),
			//array('type'=>'href','op'=>'setgenjin_log8','title'=>'处理试用情况','show'=>array('status'=>array(7))),
			//array('type'=>'href','action'=>'jy_yxw/juese6.list/setgenjin_log9','title'=>'处理交定金回访','show'=>array('status'=>array(9))),
			array('type'=>'modal','action'=>'jy_yxw/juese6.list/setstatus4','title'=>'处理已意向','show'=>array('status'=>array(3))),
			//array('type'=>'modal','op'=>'worker6id','title'=>'分配销售员','show'=>array('status'=>4)),
			array('type'=>'modal','action'=>'jy_yxw/juese6.list/worker7id','title'=>'分配体验师','show'=>array('status'=>array(33,9))),
			array('type'=>'modal','action'=>'jy_yxw/juese6.list/worker8id','title'=>'分配试用员','show'=>array('status'=>array(34,9))),
			//array('type'=>'modal','action'=>'jy_yxw/juese6.list/setclass','title'=>'分配售后群','show'=>array('status'=>array(10,35,36))),
			array('type'=>'href','action'=>'jy_yxw/juese6.list/tuiding','title'=>'退定金','show'=>array('jiaofee2'=>1)),
			array('type'=>'href','action'=>'jy_yxw/juese6.list/tuiding2','title'=>'重新退定金','show'=>array('status'=>array(113,114))),
			array('type'=>'href','action'=>'jy_yxw/juese6.list/tuifee','title'=>'退成交','show'=>array('status'=>array(10,11,36))),
			array('type'=>'href','action'=>'jy_yxw/juese6.list/tuifee2','title'=>'重新退成交','show'=>array('status'=>array(103,104))),
			array('type'=>'modal','action'=>'jy_yxw/juese6.list/looktuifee/','title'=>'退费审批不通过原因','show'=>array('status'=>array(103,104))),
			//array('type'=>'modal','action'=>'jy_yxw/juese6.list/workerheid','title'=>'设置合作人'),
		),'batch'=>$batch),
		'search'=>array(
			array('type'=>'string','width'=>'10','title'=>'手机号','name'=>'mobile','help'=>''),
			array('type'=>'string','width'=>'10','title'=>'客户名称','name'=>'title','help'=>''),
			array('name'=>'xueli','width'=>'10','title'=>'学历','type'=>'radio','options'=>'xueli_type'),
			array('name'=>'from1_type','width'=>'10','title'=>'渠道','type'=>'radio','options'=>'from1_type'),
			array('name'=>'createtime','width'=>15,'title'=>'时间段','type'=>'time_range')
		),
	);
	$return['status']=$this->member_status;
	$return['status']['all']='全部';
	$return['jibie_type']=$this->member_jibie_type;
	$return['from_type']=$this->member_from_type;
	$return['from1_type']=$this->member_from1_type;
	$return['from2_type']=$this->member_from2_type;
	$return['xueli_type']=$this->xueli_type;
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='edit'){
	if($_RQ['postdata']){
		$postdata=get_postdata();
		$this->model('member')->add($postdata);
		exi('操作成功','','/juese6.list//status=0');
	}
	if($_RQ['id']){
		$item=pdo_get('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
		if($item['birth']){
			$item['age']=date('Y')-$item['birth'];
		}
	}else{
		$item=array();
	}
	$return['item']=$item;
	$htmls=array(
		'type'=>'edit',
		'edit'=>$this->model('member')->edit_item('',5),
	);
	$return['sex']=$this->sex;
	$return['xueli_type']=$this->xueli_type;
	$return['from_type']=$this->member_from_type;
	$return['member_from1_type']=$this->member_from1_type;
	$return['member_from2_type']=$this->member_from2_type;
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='export'){
	//客户列表
	$return['params']=array();
	$params=array('workerheid'=>$_SESSION['workerid'],'uniacid'=>$_SESSION['uniacid']);
	if($_RQ['jibie_type']!='all'){
		$params['jibie_type']=intval($_RQ['jibie_type']);
	}
	$return['params']['jibie_type']=$_RQ['jibie_type'];
	if($_RQ['status']){
		$params['status']=intval($_RQ['status']);
		$return['params']['status']=$_RQ['status'];
	}
	if($_RQ['storeid']){
		$params['storeid']=intval($_RQ['storeid']);
		$return['params']['storeid']=$_RQ['storeid'];
	}
	if($_RQ['xueli']){
		$params['xueli']=intval($_RQ['xueli']);
		$return['params']['xueli']=$_RQ['xueli'];
	}
	if($_RQ['from1_type']){
		$params['from1_type']=intval($_RQ['from1_type']);
		$return['params']['from1_type']=$_RQ['from1_type'];
	}
	if(!empty($_RQ['title'])){
		$params['title like']='%'.$_RQ['title'].'%';
		$return['params']['title']=$_RQ['title'];
	}
	if(!empty($_RQ['mobile'])){
		$params['mobile']=$_RQ['mobile'];
		$return['params']['mobile']=$_RQ['mobile'];
	}
	$list=pdo_getall('jy_yxw_member',$params,$fields);
	if($list){
		foreach($list as &$item){
			$item['createtime']=date('Y/m/d H:i:s',$item['createtime']);
			$item['jibie_type']=$this->member_jibie_type[$item['jibie_type']];
			$item['from_type']=$this->member_from_type[$item['from_type']];
			$item['status']=$this->member_status[$item['status']];
			$item['xueli']=$this->xueli_type[$item['xueli']];
		}
	}
	$header=array(
		'id'=>'客户ID',
		'title'=>'客户名称',
		'mobile'=>'手机号',
		'jibie_type'=>'级别',
		'from_type'=>'渠道',
		'xueli'=>'学历',
		'status'=>'状态',
		'createtime'=>'注册时间',
	);
	model('core/tools')->export2excel($header,$list,'客户数据');
}
if($_RQ['op']=='setjibie_type'){
	if($_RQ['postdata']){
		$post=get_postdata();
		$id=$post['id'];
		$update=array('jibie_type'=>intval($post['jibie_type']));
		if($update['jibie_type']==5){
			$update['status']=-1;
		}elseif($post['status']==-1){
			$update['status']=32;
		}
		$uplog=array(
			'memberid'=>$id,
			'remark'=>'修改级别',
			'status'=>1,
			'type'=>2,
		);
		$this->model('uplog')->addgenjin_log($uplog);
		pdo_update('jy_yxw_member',$update,array('uniacid'=>$_SESSION['uniacid'],'id'=>$id));
		exi('操作成功！','','/juese6.list//status=all');
	}
	if($_RQ['id']){
		$item=pdo_get('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
	}else{
		exi('请先选择客户','error');
	}
	$return['item']=$item;	
	$htmls=array(
		'type'=>'edit',
		'desc'=>'设置级别',
	);
	$htmls['edit']=array(
		array('type'=>'radio','title'=>'设置级别','name'=>'jibie_type','options'=>'jibie_type'),
	);
	$return['jibie_type']=$this->member_jibie_type;	
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='setgenjin_log6' || $_RQ['op']=='setgenjin_log9'){
	if($_RQ['postdata']){
		$post=get_postdata();
		$this->model('uplog')->addgenjin_log($post);
		if($_RQ['op']=='setgenjin_log9'){
			if($post['status']==1){
				$status=10;
			}elseif($post['status']==0){
				$status=9;
			}elseif($post['status']==2){
				$status=9;
			}
		}else{
			if($post['status']==1){
					$status=32;
			}elseif($post['status']==0){
					$status=32;
			}elseif($post['status']==2){
					$status=32;
			}elseif($post['status']==4){
					$status=100;
			}
		}
		if($post['status']==1 && $this->genjin_totype[$post['type']]){
				$status=$this->genjin_totype[$post['type']];
		}
		$update=array('status'=>$status,'up_time'=>time());
		if($post['huifang_time'] && (!$post['status'] || $post['status']==2)){
			$update['huifang_time']=strtotime($post['huifang_time']);
		}
		pdo_update('jy_yxw_member',$update,array('uniacid'=>$_SESSION['uniacid'],'id'=>$post['memberid']));
		exi('操作成功！','','//list/status='.$status);
	}
	if($_RQ['id']){
		$item=pdo_get('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
		$item['memberid']=$_RQ['id'];
		$item['member']=$this->model('member')->member_show($item['memberid']);
		unset($item['id']);
	}else{
		exi('请先选择客户','error');
	}
	$return['item']=$item;	
	$htmls=array(
		'type'=>'edit',
		'desc'=>'跟进信息',
	);
	$htmls['edit']=array(
		array('name'=>'member','title'=>'客户信息','type'=>'member'),
		array('type'=>'copy','title'=>'客户电话','name'=>'mobile'),
		array('type'=>'text','title'=>'跟进信息','name'=>'remark'),
		array('type'=>'radio','title'=>'跟进状态','name'=>'status','options'=>'status'),
		array('type'=>'radio','title'=>'跟进效果','name'=>'type','options'=>'genjin_type','show'=>array('status'=>array(1))),
		array('type'=>'time','title'=>'回访时间','name'=>'huifang_time','show'=>array('status'=>array(0,2))),
	);
	$return['status']=$this->genjin_status;
	if($_RQ['op']=='setgenjin_log9'){
		$return['genjin_type']=$this->genjin_type5;
		unset($htmls['edit'][3]);
	}else{
		if($item['from_type']==2){
			$return['genjin_type']=$this->genjin_type0;
		}else{
			$return['genjin_type']=$this->genjin_type2;
		}
	}
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='setstatus4'){
	if($_RQ['postdata']){
		$post=get_postdata();
		$id=$post['memberid'];
		$update=array('up_time'=>time());
		if(!$post['setstatus']){
			$update['status']=4;
			$post['type']=4;
			$post['status']=2;
		}
		if($post['setstatus']==1){
			$update['status']=2;
			$post['type']=3;
			$post['status']=2;
		}
		$post['remark']='客户已意向';
		$this->model('uplog')->addgenjin_log($post);
		pdo_update('jy_yxw_member',$update,array('uniacid'=>$_SESSION['uniacid'],'id'=>$id));
		exi('操作成功！','','//list/status=4');
	}
	if($_RQ['id']){
		$item=pdo_get('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
		$item['setstatus']=0;
		$item['memberid']=$item['id'];
		unset($item['id']);
	}else{
		exi('请先选择客户','error');
	}
	$return['item']=$item;	
	$htmls=array(
		'type'=>'edit',
		'desc'=>'处理意向',
	);
	$htmls['edit']=array(
		array('type'=>'radio','title'=>'意向状态','name'=>'setstatus','options'=>'status'),
		array('type'=>'text','title'=>'未按时意向原因','name'=>'remark','show'=>array('status'=>array(1))),
	);
	$return['status']=array('已意向','未按时意向');	
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='worker7id'){
	if($_RQ['postdata']){
		$post=get_postdata();
		$id=$post['id'];
		$update=array('ti5_time'=>time(),'up_time'=>time(),'worker7id'=>intval($post['worker7id']));
		if($post['worker7id']){
			$update['status']=5;
		}
		if(!$post['worker7id']){
			$update['status']=33;
		}
		$uplog=array(
			'memberid'=>$id,
			'remark'=>'分配体验师',
			'status'=>1,
			'type'=>2,
		);
		$this->model('uplog')->addgenjin_log($uplog);
		pdo_update('jy_yxw_member',$update,array('uniacid'=>$_SESSION['uniacid'],'id'=>$id));
		exi('操作成功！','','//list/status=33');
	}
	if($_RQ['id']){
		$item=pdo_get('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
	}else{
		exi('请先选择客户','error');
	}
	$return['item']=$item;	
	$htmls=array(
		'type'=>'edit',
		'desc'=>'分配体验师',
	);
	$htmls['edit']=array(
		array('type'=>'select','title'=>'分配体验师','name'=>'worker7id','options'=>'workers'),
	);
	$return['workers']=$this->getall('worker',array('juese'=>7,'storeid'=>$_SESSION['storeid'],'uniacid'=>$_SESSION['uniacid']),array('id','title'),'id');	
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='worker8id'){
	if($_RQ['postdata']){
		$post=get_postdata();
		$id=$post['id'];
		$update=array('up_time'=>time(),'worker8id'=>intval($post['worker8id']));
		if($post['worker8id']){
			$update['status']=7;
		}
		if(!$post['worker8id']){
			$update['status']=34;
		}
		$uplog=array(
			'memberid'=>$id,
			'remark'=>'分配试用员',
			'status'=>1,
			'type'=>2,
		);
		$this->model('uplog')->addgenjin_log($uplog);
		pdo_update('jy_yxw_member',$update,array('uniacid'=>$_SESSION['uniacid'],'id'=>$id));
		exi('操作成功！','','//list/status=34');
	}
	if($_RQ['id']){
		$item=pdo_get('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
	}else{
		exi('请先选择客户','error');
	}
	$return['item']=$item;	
	$htmls=array(
		'type'=>'edit',
		'desc'=>'分配试用员',
	);
	$htmls['edit']=array(
		array('type'=>'select','title'=>'分配试用员','name'=>'worker8id','options'=>'workers'),
	);
	$return['workers']=$this->getall('worker',array('juese'=>8,'storeid'=>$_SESSION['storeid'],'uniacid'=>$_SESSION['uniacid']),array('id','title'),'id');	
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='workerheid'){
	if($_RQ['postdata']){
		$post=get_postdata();
		$id=$post['id'];
		$update=array('workerheid'=>intval($post['workerheid']));
		$uplog=array(
			'memberid'=>$id,
			'remark'=>'设置合作人',
			'status'=>1,
			'type'=>2,
		);
		$this->model('uplog')->addgenjin_log($uplog);
		pdo_update('jy_yxw_member',$update,array('uniacid'=>$_SESSION['uniacid'],'id'=>$id));
		pdo_update('jy_yxw_infee_log',$update,array('uniacid'=>$_SESSION['uniacid'],'memberid'=>$id));
		exi('操作成功！','','//list/status=all');
	}
	if($_RQ['id']){
		$item=pdo_get('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
	}else{
		exi('请先选择客户','error');
	}
	$return['item']=$item;	
	$htmls=array(
		'type'=>'edit',
		'desc'=>'设置合作人',
	);
	$htmls['edit']=array(
		array('type'=>'select','title'=>'设置合作人','name'=>'workerheid','options'=>'workers'),
	);
	$shouhouid=$this->getcolumn('store',array('id'=>$_SESSION['storeid'],'uniacid'=>$_SESSION['uniacid']),'shouhouid');
	$return['workers']=$this->getall('worker',array('juese'=>array(6,9,10,11),'id <>'=>$_SESSION['workerid'],'storeid'=>array($_SESSION['storeid'],$shouhouid),'uniacid'=>$_SESSION['uniacid']),array('id','title','storeid'),'id');	
	foreach($return['workers'] as &$wv){
		if($wv['storeid']==$_SESSION['storeid']){
			$wv['title']='[本店]'.$wv['title'];
		}else{
			$wv['title']='[售后基地]'.$wv['title'];
		}
	}
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='worker9id'){
	if($_RQ['postdata']){
		$post=get_postdata();
		$id=$post['id'];
		$update=array('up_time'=>time(),'worker9id'=>intval($post['worker9id']));
		if($post['worker9id']){
			$update['status']=36;
		}
		if(!$post['worker9id']){
			$update['status']=35;
		}
		$uplog=array(
			'memberid'=>$id,
			'remark'=>'分配售后助理员',
			'status'=>1,
			'type'=>2,
		);
		$this->model('uplog')->addgenjin_log($uplog);
		pdo_update('jy_yxw_member',$update,array('uniacid'=>$_SESSION['uniacid'],'id'=>$id));
		exi('操作成功！','','//list/status=35');
	}
	if($_RQ['id']){
		$item=pdo_get('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
	}else{
		exi('请先选择客户','error');
	}
	$return['item']=$item;	
	$htmls=array(
		'type'=>'edit',
		'desc'=>'分配售后助理员',
	);
	$htmls['edit']=array(
		array('type'=>'select','title'=>'分配售后助理员','name'=>'worker9id','options'=>'workers','help'=>'分配给售后基地的【售后助理员】'),
	);
	$shouhouid=$this->getcolumn('store',array('id'=>$_SESSION['storeid'],'uniacid'=>$_SESSION['uniacid']),'shouhouid');
	$return['workers']=$this->getall('worker',array('juese'=>9,'storeid'=>$shouhouid,'uniacid'=>$_SESSION['uniacid']),array('id','title'),'id');	
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='setclass'){
	if($_RQ['postdata']){
		$post=get_postdata();
		$id=$post['id'];
		if(!$post['classid']){
			exi('请选择售后群！','error');
		}
		$post['memberid']=$post['id'];
		$this->model('yonghu')->addyonghu($post,$post['shouhouid']);
		$class=$this->get('class',array('id'=>$post['classid'],'uniacid'=>$_SESSION['uniacid']));
		$uplog=array(
			'memberid'=>$id,
			'remark'=>'分配售后群',
			'status'=>1,
			'type'=>2,
		);
		$this->model('uplog')->addgenjin_log($uplog);
		pdo_update('jy_yxw_member',array('status'=>11,'worker11id'=>$class['workerid']),array('uniacid'=>$_SESSION['uniacid'],'id'=>$id));
		exi('操作成功！','','//list/status=35');
	}
	if($_RQ['id']){
		$item=pdo_get('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
		$item['classid']=$item['classid']?:$item['toclassid'];
	}else{
		exi('请先选择客户','error');
	}
	$shouhouid=$this->getcolumn('store',array('id'=>$_SESSION['storeid'],'uniacid'=>$_SESSION['uniacid']),'shouhouid');
	$item['shouhouid']=$shouhouid;
	$return['item']=$item;	
	$htmls=array(
		'type'=>'edit',
		'desc'=>'分配售后群',
	);
	$htmls['edit']=array(
		array('type'=>'select','title'=>'分配售后群','name'=>'classid','options'=>'class','help'=>'选择售后基地的[未开班的售后群]'),
	);
	$return['class']=$this->getall('class',array('status'=>0,'storeid'=>$shouhouid,'uniacid'=>$_SESSION['uniacid']),array('id','title'),'id');
	$return['htmls']=$htmls;
	exi($return);
}
//成交提交
if($_RQ['op']=='jiaofee1'){
	if($_RQ['postdata']){
		$post=get_postdata();
		if(!$post['tofee']){
			exi('请填写成交费用！','error');
		}
		if($post['bufee']>0 && (!$post['bankno'] || !$post['banktitle'] || !$post['bankimg'])){
			exi('填写补贴费用，银行信息必填！','error');
		}
		if(!$post['cardno'] || !$post['cardimg1'] || !$post['cardimg2'] || !$post['xueli'] || !$post['xueliimg']){
			exi('请完善客户成交信息！','error');
		}
		if(!$post['danganimage1'] || !$post['danganimage2'] || !$post['px_file'] || !$post['rx_file'] || !$post['jj_file']){
			exi('请完善客户档案信息！','error');
		}
		if(($post['pay_type']==1 || $post['pay_type']==2 || $post['pay_type']==3) && !$post['fen_file']){
			exi('请上传《分期承诺书》！','error');
		}
		$id=$post['id'];
		if($post['memberid'] && $id){
			$memberid=$post['memberid'];
		}else{
			$memberid=$id;
		}	
		$member=pdo_get('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'id'=>$memberid),array('worker5id','from1_type','from2_type'));
		$data=array(
				'tofee'=>$post['tofee'],
				'classid'=>$post['classid'],
				'toremark'=>trim($post['toremark']),
				'workerid'=>intval($_SESSION['workerid']),
				'worker5id'=>$member['worker5id'],
				'worker6id'=>$_SESSION['workerid'],
				'from1_type'=>$member['from1_type'],
				'from2_type'=>$member['from2_type'],
				'pay_type'=>intval($post['pay_type']),
				'daipay_type'=>intval($post['daipay_type']),
				'dai_time'=>intval($post['dai_time']),
				'shouhoufee'=>trim($post['shouhoufee']),
				'bufee'=>trim($post['bufee']),
				'fen_file'=>ijson_encode($post['fen_file']),
				'fen_log'=>ijson_encode($post['fen_log']),
				'buy_time'=>strtotime($post['buy_time']),
				'status'=>0,
		);
		if($post['memberid'] && $id){
			$memberid=$post['memberid'];
			if(!$post['storeid']){
				$data['storeid']=$_SESSION['storeid'];
			}
			$this->update('infee_log',$data,array('uniacid'=>$_SESSION['uniacid'],'id'=>$id));
		}else{
			$data['uniacid']=$_SESSION['uniacid'];
			$data['storeid']=$_SESSION['storeid'];
			$data['memberid']=$id;
			$data['type']=1;
			$data['createtime']=time();
			$this->insert('infee_log',$data);
			$memberid=$id;
		}
		$update=array(
			'toclassid'=>$post['classid'],
			'buy_time'=>strtotime($post['buy_time']),
			'status'=>37,
			'cardno'=>$post['cardno'],
			'cardimg1'=>$post['cardimg1'],
			'cardimg2'=>$post['cardimg2'],
			'xueli'=>$post['xueli'],
			'xueliimg'=>$post['xueliimg'],
			'bankno'=>$post['bankno'],
			'banktitle'=>$post['banktitle'],
			'bankimg'=>$post['bankimg'],
		);
		$uplog=array(
			'memberid'=>$post['memberid']?:$id,
			'remark'=>'提交成交',
			'status'=>1,
			'type'=>2,
		);
		$this->model('uplog')->addgenjin_log($uplog);
		$oldstatus=pdo_getcolumn('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'id'=>$post['memberid']?:$id),'status');
		$update['oldstatus']=$oldstatus;
		pdo_update('jy_yxw_member',$update,array('uniacid'=>$_SESSION['uniacid'],'id'=>$post['memberid']?:$id));
		$dangan=array(
			'pay_type'=>intval($post['pay_type']),
			'fen_file'=>ijson_encode($post['fen_file']),
			'danganimage1'=>ijson_encode($post['danganimage1']),
			'danganimage2'=>ijson_encode($post['danganimage2']),
			'px_file'=>ijson_encode($post['px_file']),
			'rx_file'=>ijson_encode($post['rx_file']),
			'jj_file'=>ijson_encode($post['jj_file']),
		);
		$this->model('uplog')->updangan($dangan,$memberid);
		exi('操作成功！','','//list/status=2');
	}
	if($_RQ['id']){
		$item=pdo_get('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
		$item['memberid']=0;
		if($item['status']==38){
			$infee_log=pdo_get('jy_yxw_infee_log',array('type'=>1,'status'=>2,'uniacid'=>$_SESSION['uniacid'],'memberid'=>$item['id']),'','id desc');
		}if($item['status']==105){
			$infee_log=pdo_get('jy_yxw_infee_log',array('type'=>1,'status'=>4,'uniacid'=>$_SESSION['uniacid'],'memberid'=>$item['id']),'','id desc');
		}
		if($infee_log['id']){
			$dangan=pdo_get('jy_yxw_dangan',array('uniacid'=>$_SESSION['uniacid'],'memberid'=>$item['id']));
			$infee_log['fen_log']=json_decode($infee_log['fen_log'],true);
			$infee_log['title']=$item['title'];
			$infee_log['xueliimg']=$item['xueliimg'];
			$infee_log['xueli']=$item['xueli'];
			$infee_log['cardno']=$item['cardno'];
			$infee_log['cardimg1']=$item['cardimg1'];
			$infee_log['cardimg2']=$item['cardimg2'];
			$infee_log['bankno']=$item['bankno'];
			$infee_log['banktitle']=$item['banktitle'];
			$infee_log['bankimg']=$item['bankimg'];
			$infee_log['fen_file']=json_decode($dangan['fen_file'],true);
			$infee_log['danganimage1']=json_decode($dangan['danganimage1'],true);
			$infee_log['danganimage2']=json_decode($dangan['danganimage2'],true);
			$infee_log['px_file']=json_decode($dangan['px_file'],true);
			$infee_log['rx_file']=json_decode($dangan['rx_file'],true);
			$infee_log['jj_file']=json_decode($dangan['jj_file'],true);
			$infee_log['istip']=1;
			$item=$infee_log;
		}
	}else{
		exi('请先选择客户','error');
	}
	$basic=$this->plugin_setting('basic');
	$item['shouhoufee']=$basic['shouhoufee'.$item['xueli']];
	$item['buy_time']=$item['buy_time']?date('Y-m-d H:i:s',$item['buy_time']):date('Y-m-d H:i:s');
	$return['item']=$item;
	$htmls=array(
		'type'=>'edit',
		'desc'=>'售后成交',
	);
	$htmls['edit']=array(
		array('type'=>'tip','title'=>'审核不通过的原因：'.$item['remark'],'show'=>array('istip'=>1)),
		array('type'=>'copy','title'=>'售后姓名','name'=>'title'),
		//array('type'=>'select','title'=>'成交售后群','name'=>'classid','options'=>'class'),
		array('type'=>'copy','title'=>'售后成本','name'=>'shouhoufee'),
		array('type'=>'unitstring','unit'=>'元','title'=>'成交费','name'=>'tofee','must'=>true),
		array('type'=>'unitstring','unit'=>'元','title'=>'补贴费用','name'=>'bufee'),
		array('type'=>'time','unit'=>'元','title'=>'成交时间','name'=>'buy_time'),
		array('type'=>'radio','options'=>'pay_types','title'=>'支付方式','name'=>'pay_type'),
		array('type'=>'radio','options'=>'daipay_types','title'=>'贷款方式','name'=>'daipay_type','show'=>array('pay_type'=>array(2,3))),
		array('type'=>'images','title'=>'现金分期承诺书','name'=>'fen_file','show'=>array('pay_type'=>1)),
		array('type'=>'images','title'=>'贷款分期承诺书','name'=>'fen_file','show'=>array('pay_type'=>array(2,3))),
		array('type'=>'array','title'=>'分期明细','name'=>'fen_log','show'=>array('pay_type'=>1),'add_tip'=>'添加一个分期',
			'list'=>array(
					array('type'=>'unitstring','unit'=>'元','name'=>'fee','title'=>'当期金额'),
					array('type'=>'string','name'=>'time','title'=>'当期时间'),
			),
			'details'=>array(
					array('type'=>'unitstring','unit'=>'元','name'=>'fee','title'=>'当期金额'),
					array('type'=>'time','name'=>'time','title'=>'当期时间'),
			)
		),
		array('type'=>'text','title'=>'备注','name'=>'toremark'),
		array('type'=>'help','title'=>'完善客户信息'),
		array('type'=>'image','title'=>'学信网/证书','name'=>'xueliimg','must'=>true),
		array('type'=>'radio','title'=>'学历','name'=>'xueli','options'=>'xueli_type','must'=>true),
		array('type'=>'string','title'=>'身份证号码','name'=>'cardno','must'=>true),
		array('type'=>'image','title'=>'身份证正面','name'=>'cardimg1','must'=>true),
		array('type'=>'image','title'=>'身份证背面','name'=>'cardimg2','must'=>true),
		array('type'=>'string','title'=>'银行卡号','name'=>'bankno'),
		array('type'=>'string','title'=>'银行支行','name'=>'banktitle'),
		array('type'=>'image','title'=>'银行卡正面照片','name'=>'bankimg'),
		array('type'=>'images','title'=>'用户档案照片A面','name'=>'danganimage1','must'=>true),
		array('type'=>'images','title'=>'用户档案照片B面','name'=>'danganimage2','must'=>true),
		array('type'=>'images','title'=>'用户培训协议','name'=>'px_file','must'=>true),
		array('type'=>'images','title'=>'用户入学协议','name'=>'rx_file','must'=>true),
		array('type'=>'images','title'=>'用户交接表','name'=>'jj_file','must'=>true),
	);
	$shouhouid=$this->getcolumn('store',array('id'=>$_SESSION['storeid'],'uniacid'=>$_SESSION['uniacid']),'shouhouid');
	$return['class']=$this->getall('class',array('status'=>0,'storeid'=>$shouhouid,'uniacid'=>$_SESSION['uniacid']),array('id','title'),'id');
	$return['pay_types']=$this->pay_types;
	$return['daipay_types']=$this->daipay_types;
	$return['xueli_type']=$this->xueli_type;
	$return['htmls']=$htmls;
	exi($return);
}
//定金提交
if($_RQ['op']=='jiaofee2'){
	if($_RQ['postdata']){
		$post=get_postdata();
		$id=$post['id'];
		if($post['memberid'] && $id){
			$memberid=$post['memberid'];
		}else{
			$memberid=$id;
		}	
		$member=pdo_get('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'id'=>$memberid),array('worker5id','from1_type','from2_type'));
		$data=array(
			'tofee'=>$post['tofee'],
			'classid'=>$post['classid'],
			'toremark'=>trim($post['toremark']),
			'workerid'=>intval($_SESSION['workerid']),
			'worker5id'=>$member['worker5id'],
			'worker6id'=>$_SESSION['workerid'],
			'from1_type'=>$member['from1_type'],
			'from2_type'=>$member['from2_type'],
			'worker6id'=>$_SESSION['workerid'],
			'status'=>0,
		);
		if($post['memberid'] && $id){
			if(!$post['storeid']){
				$data['storeid']=$_SESSION['storeid'];
			}
			$this->update('infee_log',$data,array('uniacid'=>$_SESSION['uniacid'],'id'=>$id));
		}else{
			$data['uniacid']=$_SESSION['uniacid'];
			$data['storeid']=$_SESSION['storeid'];
			$data['memberid']=$id;
			$data['type']=2;
			$data['createtime']=time();
			$this->insert('infee_log',$data);
		}
		$uplog=array(
			'memberid'=>$post['memberid']?:$id,
			'remark'=>'提交定金',
			'status'=>1,
			'type'=>2,
		);
		$this->model('uplog')->addgenjin_log($uplog);
		$oldstatus=pdo_getcolumn('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'id'=>$post['memberid']?:$id),'status');
		$update['oldstatus']=$oldstatus;
		pdo_update('jy_yxw_member',array('toclassid'=>$post['classid'],'ding_time'=>time(),'status'=>9),array('uniacid'=>$_SESSION['uniacid'],'id'=>$post['memberid']?:$id));
		exi('操作成功！','','//list/status=2');
	}
	if($_RQ['id']){
		$item=pdo_get('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
		$item['memberid']=0;
		if($item['status']==39){
			$infee_log=pdo_get('jy_yxw_infee_log',array('type'=>2,'status'=>2,'uniacid'=>$_SESSION['uniacid'],'memberid'=>$item['id']),'','id desc');
		}
		if($infee_log['id']){
			$infee_log['title']=$item['title'];
			$infee_log['xueli']=$item['xueli'];
			$infee_log['istip']=1;
			$item=$infee_log;
		}
	}else{
		exi('请先选择客户','error');
	}
	$return['item']=$item;	
	$htmls=array(
		'type'=>'edit',
		'desc'=>'售后交定金',
	);
	$htmls['edit']=array(
		array('type'=>'tip','title'=>'审核不通过的原因：'.$item['remark'],'show'=>array('istip'=>1)),
		array('type'=>'copy','title'=>'售后姓名','name'=>'title'),
		//array('type'=>'select','title'=>'成交售后群','name'=>'classid','options'=>'class'),
		array('type'=>'unitstring','unit'=>'元','title'=>'交定金费','name'=>'tofee'),
		array('type'=>'text','title'=>'备注','name'=>'toremark'),
	);
	$shouhouid=$this->getcolumn('store',array('id'=>$_SESSION['storeid'],'uniacid'=>$_SESSION['uniacid']),'shouhouid');
	$return['class']=$this->getall('class',array('status'=>0,'storeid'=>$shouhouid,'uniacid'=>$_SESSION['uniacid']),array('id','title'),'id');
	$return['pay_types']=$this->pay_types;
	$return['daipay_types']=$this->daipay_types;
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='tuiding' || $_RQ['op']=='tuiding2'){
	if($_RQ['postdata']){
		$post=get_postdata();
		$id=$post['id'];
		$update=array('up_time'=>time(),'status'=>111);
		if($_RQ['op']=='tuiding2'){
			$data=array(
				'fee'=>$post['fee'],
				'isfee'=>$post['isfee'],
				'remark'=>trim($post['remark']),
				'tuiimage'=>trim($post['tuiimage']),
				'status'=>0,
			);
			pdo_update('jy_yxw_tuifee_log',$data,array('uniacid'=>$_SESSION['uniacid'],'id'=>$id));
			$id=$post['memberid'];
		}else{
			$id=$post['id'];
			$data=array(
				'memberid'=>$id,
				'fee'=>$post['fee'],
				'isfee'=>$post['isfee'],
				'remark'=>trim($post['remark']),
				'tuiimage'=>trim($post['tuiimage']),
				'oldstatus'=>$post['status'],
				'type'=>2,
			);
			$data['uniacid']=$_SESSION['uniacid'];
			$data['storeid']=$_SESSION['storeid'];
			$data['createtime']=time();
			$this->insert('tuifee_log',$data);
		}
		$uplog=array(
			'memberid'=>$id,
			'remark'=>'退定金',
			'status'=>1,
			'type'=>2,
		);
		$this->model('uplog')->addgenjin_log($uplog);
		$oldstatus=pdo_getcolumn('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'id'=>$id),'status');
		$update['oldstatus']=$oldstatus;
		pdo_update('jy_yxw_member',$update,array('uniacid'=>$_SESSION['uniacid'],'id'=>$id));
		$oldstatus=pdo_getcolumn('jy_yxw_yonghu',array('uniacid'=>$_SESSION['uniacid'],'memberid'=>$id),'status');
		$update['oldstatus']=$oldstatus;
		pdo_update('jy_yxw_yonghu',$update,array('uniacid'=>$_SESSION['uniacid'],'memberid'=>$id));
		exi('操作成功！','','//list/status=111');
	}
	if($_RQ['id']){
		if($_RQ['op']=='tuiding2'){
			$member=pdo_get('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
			$item=pdo_get('jy_yxw_tuifee_log',array('uniacid'=>$_SESSION['uniacid'],'memberid'=>$member['id']),'','id desc');
			$item['title']=$member['title'];
		}else{
			$item=pdo_get('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
		}
	}else{
		exi('请先选择客户','error');
	}
	$return['item']=$item;	
	$htmls=array(
		'type'=>'edit',
		'desc'=>$_RQ['op']=='tuiding2'?'重新发起退定金':'发起退定金',
	);
	$htmls['edit']=array(
		array('type'=>'tip','title'=>'发起“退定金”申请，成交成功后退定金，向“店长”发起，店长确认达到“财务”系统。'),
		array('type'=>'copy','title'=>'售后姓名','name'=>'title'),
		array('type'=>'unitstring','unit'=>'元','title'=>'退费金额','name'=>'fee'),
		array('type'=>'unitstring','unit'=>'元','title'=>'已收取金额','name'=>'isfee'),
		array('type'=>'image','title'=>'退定金协议图片','name'=>'tuiimage'),
		array('type'=>'text','title'=>'退定金原因','name'=>'remark'),
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='tuifee' || $_RQ['op']=='tuifee2'){
	if($_RQ['postdata']){
		$post=get_postdata();
		$id=$post['id'];
		$update=array('up_time'=>time(),'status'=>101);
		if($_RQ['op']=='tuifee2'){
			$data=array(
				'fee'=>$post['fee'],
				'isfee'=>$post['isfee'],
				'remark'=>trim($post['remark']),
				'tuiimage'=>trim($post['tuiimage']),
				'status'=>0,
			);
			pdo_update('jy_yxw_tuifee_log',$data,array('uniacid'=>$_SESSION['uniacid'],'id'=>$id));
			$id=$post['memberid'];
		}else{
			$id=$post['id'];
			$data=array(
				'memberid'=>$id,
				'fee'=>$post['fee'],
				'isfee'=>$post['isfee'],
				'remark'=>trim($post['remark']),
				'tuiimage'=>trim($post['tuiimage']),
				'oldstatus'=>$post['status'],
				'type'=>1,
			);
			$data['uniacid']=$_SESSION['uniacid'];
			$data['storeid']=$_SESSION['storeid'];
			$data['createtime']=time();
			$this->insert('tuifee_log',$data);
		}
		$uplog=array(
			'memberid'=>$id,
			'remark'=>'退成交',
			'status'=>1,
			'type'=>2,
		);
		$this->model('uplog')->addgenjin_log($uplog);
		$oldstatus=pdo_getcolumn('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'id'=>$id),'status');
		$update['oldstatus']=$oldstatus;
		pdo_update('jy_yxw_member',$update,array('uniacid'=>$_SESSION['uniacid'],'id'=>$id));
		$oldstatus=pdo_getcolumn('jy_yxw_yonghu',array('uniacid'=>$_SESSION['uniacid'],'memberid'=>$id),'status');
		$update['oldstatus']=$oldstatus;
		pdo_update('jy_yxw_yonghu',$update,array('uniacid'=>$_SESSION['uniacid'],'memberid'=>$id));
		exi('操作成功！','','//list/status=101');
	}
	if($_RQ['id']){
		if($_RQ['op']=='tuifee2'){
			$member=pdo_get('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
			$item=pdo_get('jy_yxw_tuifee_log',array('uniacid'=>$_SESSION['uniacid'],'memberid'=>$member['id']),'','id desc');
			$item['title']=$member['title'];
		}else{
			$item=pdo_get('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
		}
	}else{
		exi('请先选择客户','error');
	}
	$return['item']=$item;	
	$htmls=array(
		'type'=>'edit',
		'desc'=>$_RQ['op']=='tuifee2'?'重新发起退成交':'发起退成交',
	);
	$htmls['edit']=array(
		array('type'=>'tip','title'=>'发起“退成交”申请，成交成功后退成交，向“店长”发起，店长确认达到“财务”系统。'),
		array('type'=>'copy','title'=>'售后姓名','name'=>'title'),
		array('type'=>'unitstring','unit'=>'元','title'=>'退费金额','name'=>'fee'),
		array('type'=>'unitstring','unit'=>'元','title'=>'已收取金额','name'=>'isfee'),
		array('type'=>'image','title'=>'退成交协议图片','name'=>'tuiimage'),
		array('type'=>'text','title'=>'退成交原因','name'=>'remark'),
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='looktuifee'){
	if($_RQ['id']){
		$member=pdo_get('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
		$item=pdo_get('jy_yxw_tuifee_log',array('uniacid'=>$_SESSION['uniacid'],'memberid'=>$member['id']),'','id desc');
		$item['title']=$member['title'];
	}else{
		exi('请先选择客户','error');
	}
	$return['item']=$item;	
	$htmls=array(
		'type'=>'look',
	);
	$htmls['look']=array(
		array('type'=>'tip','title'=>'发起“退成交”申请，成交成功后退成交，向“店长”发起，店长确认达到“财务”系统。'),
		array('type'=>'string','title'=>'售后姓名','name'=>'title'),
		array('type'=>'text','title'=>'店长审批不通过原因','name'=>'remark1'),
		array('type'=>'text','title'=>'财务审批不通过原因','name'=>'remark14'),
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='del'){
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
	}else{
		$del=array();
	}
	if($_RQ['id']){
		$del[]=$_RQ['id'];
	}
	foreach($del as $id){
		$id=intval($id);
		if($id){
			$this->model('member')->check_del($id,'xiaoshou');
			pdo_delete('jy_yxw_member',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		}
	}
	exi('删除成功！');
}